﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using SuperRyoninRPG.Controller;
using SuperRyoninRPG.Main;

namespace SuperRyoninRPG.Characters.Items
{
	public class Mashroom:Item
	{
		


		public Mashroom(Stage stage, Vector2 position, int frameWidth,string name)
			: base(stage, position, frameWidth,name)
		{
		}

		protected override void OnUpdate(GameTime gameTime)
		{
			base.OnUpdate(gameTime);
		}

		protected override void GetInput(GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState,
			TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation)
		{
			if (this.IsAppearing)
			{
				return;
			}

			var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

			// 歩く方向の側面に基づいてタイルの位置を計算します。
			float posX = this.Position.X + this.LocalBounds.Width / 2 * (int)this.Direction;
			int tileX = (int)Math.Floor(posX / Tile.Width) - (int)this.Direction;
			var tileY = (int)Math.Floor(this.Position.Y / Tile.Height);


				// 障壁に衝突しようとした場合、または断崖に落下しようとした場合、
				// 待機を始めます。
				if (this.Stage.GetCollision(tileX + (int)this.Direction, tileY - 1) == TileCollision.Impassable)
				{
					this.Direction = (FaceDirection)(-(int)this.Direction);
				}
				else
				{
					if (this.Direction == FaceDirection.Right)
					{
						this.Movement = 1;
					}
					else
					{
						this.Movement = -1;
					}
				}
			
		}

		


		
	}
}
